<?php 
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
  MYDCONN();
  $TimeType = 'TimeClose';
  $OLDPAR = 0;
  $TitleTotal = '0.00';
  $TOTAL = '0.00';
  $SUBTOTAL = '0.00';
  ?>
<table width="100%"  border="0" cellspacing="10" cellpadding="1">
    <tr>
      <td><span class="style8">RelatÓrio de Despesas</span></td>
      <td rowspan="2"></td>
    </tr>
    <tr>
      <td>
	  <?php echo 'De '.$_POST['Time'].' a '.$_POST['TimeEnd'];?>
      Total:
      <?php
	 $TAm = $GLOBALS['MYD']->db_array("SELECT 
					SUM(a.Amount) AS Results
				FROM ccenter_invarticles AS a
				INNER JOIN ccenter_invoices AS b ON a.RefInvoice = b.Ref
				WHERE DATE(b.{$TimeType}) BETWEEN '{$_POST['Time']}' AND '{$_POST['TimeEnd']}'
				AND a.Status != 5
				AND b.Status = 2
				AND b.Type != 8
				GROUP BY b.RefCurrency"); 
	if (isset($TAm[1]['Results'])){$TitleTotal = $TAm[1]['Results'];}
		echo $__sys['CurrencyISO'].' '.$TitleTotal;?></td>
    </tr>
  </table>

<?php
'<script charset="utf-8"  type="text/JavaScript">window.print();</script>';
 if ($_POST['Typo'] == 1) { 
include($GLOBALS['PAD']."Modules/CentrodeCustos/Templates/screen.report.php");
} elseif ($_POST['Typo'] == 2) {
include($GLOBALS['PAD']."Modules/CentrodeCustos/Templates/report.list.php");
} elseif ($_POST['Typo'] == 3) {
include($GLOBALS['PAD']."Modules/CentrodeCustos/Templates/report.balancete.php");
} elseif ($_POST['Typo'] == 4) {
include($GLOBALS['PAD']."Modules/CentrodeCustos/Templates/report.balancete.php");
}?>